package it.win4buy.presentations
{
    import flash.events.IEventDispatcher;

    import it.win4buy.entities.UserDataVO;
    import it.win4buy.events.UtilityEvent;
    import it.win4buy.models.ApplicationModel;
    import it.win4buy.utility.LoggerUtilty;

    import mx.controls.Alert;

    /**
     *
     *	autore:
     *  pierangelo.mancusi@gmail.com
     *
     */

    public class ControlBarPlaceHolderPM
    {



        //-------------------------------------------
        //
        // Injected properties
        //
        //-------------------------------------------

        [Dispatcher]
        public var dispatcher:IEventDispatcher;


        [Inject]
        public var applicationModel:ApplicationModel;


        [Inject]
        public var log:LoggerUtilty;

        //-------------------------------------------
        //
        // Private Properties
        //
        //-------------------------------------------

        /**
         * User Data
         */

        private var _user:UserDataVO;

        //-------------------------------------------
        //
        // Getters / Setters
        //
        //-------------------------------------------

        [Bindable]
        /**
         * User Data
         */
        public function get user():UserDataVO
        {
            return _user;
        }

        /**
         * @private
         */
        public function set user(value:UserDataVO):void
        {
            _user=value;
        }



        //-------------------------------------------
        //
        // Constructor
        //
        //-------------------------------------------

        public function ControlBarPlaceHolderPM()
        {
        }

        //-------------------------------------------
        //
        // Mediator Handlers
        //
        //-------------------------------------------

        [EventHandler(event="UtilityEvent.REFRESH_BINDING", priority="990")]
        public function refreshBindigs(event:UtilityEvent):void
        {
            log.logToConsole(this, "refreshBindigs");
            user=applicationModel.userData;

            user.credits=applicationModel.userData.credits;
            user.freeCredits=applicationModel.userData.freeCredits;


        }



    }
}